home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / What's New? / Development Kits / Mac OS / USB DDK 1.4.6f4 / Examples / USBEnetSample / USBEnet.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-23  |  3.4 KB  |  148 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        USBEnet.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1998-2000 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                xxx put dri here xxx
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            xxx put technology here xxx
  17.  
  18. */
  19.  
  20. #ifndef    _USBENET_
  21. #define    _USBENET_
  22.  
  23. #include <USB.h>
  24.  
  25. #include "EnetShim.h"
  26.  
  27. // Debug stuff
  28.  
  29. #define DebugOn        0                        // This is the master switch (On > 0)
  30. #define LogOn        0                        // On > 0 (DebugOn must also be on)
  31. #define LogBug        0                        // On > 0 (DebugOn and LogOn (to log data) must also be on) - dumps to the debugger
  32. #define FullTrace    0                        // On > 0 Be careful with this as it traces everything (DebugOn must also be on)
  33.  
  34. #if (DebugOn > 0)
  35. #define SLevel        4                        // Status level for USB Expert Log
  36. #else
  37. #define SLevel        5                        // Status level for USB Expert Log
  38. #endif
  39.  
  40. #if (DebugOn > 0)
  41. #define DebugMessage(s)        DebugStr(s)
  42. #else
  43. #define DebugMessage(s)
  44. #endif
  45.  
  46. #if (DebugOn > 0)
  47. #define Bugon        " - Debug"
  48. #else
  49. #define Bugon
  50. #endif
  51.  
  52. #if ((DebugOn > 0) && (LogOn > 0))
  53. #define LogData(x, y, z)    USBLogData(x, y, z)
  54. #else
  55. #define LogData(x, y, z)
  56. #endif
  57.  
  58. #if (DebugOn > 0)
  59.     #if (LogBug > 0)
  60.         #define TraceMessage(x, s)    {if (FullTrace > 0) DebugStr(s); else if (x) DebugStr(s);}
  61.     #else
  62.         #define TraceMessage(x, s)    {if (FullTrace > 0) USBStatus(SLevel, 0, s, 0); else if (x) USBStatus(SLevel, 0, s, 0);}
  63.     #endif
  64. #else
  65.     #define TraceMessage(x, s)
  66. #endif
  67.  
  68. #if (DebugOn > 0)
  69.     #if (LogBug > 0)
  70.         #define StatusMessage(a, s, c)    DebugStr(s)
  71.     #else
  72.         #define StatusMessage(a, s, c)    USBStatus(SLevel, a, s, c)
  73.     #endif
  74. #else
  75.     #define StatusMessage(a, s, c)    USBStatus(SLevel, a, s, c)
  76. #endif
  77.  
  78.  
  79. #if (DebugOn > 0)
  80. #define noteError(s)    gEnetGlobals.errorString = s;
  81. #else
  82. #define noteError(s)
  83. #endif
  84.  
  85. //    Change these for other devices etc.
  86.  
  87. #define kUSBVendorID    0                                // None
  88. #define kUSBProductID     0                                // None
  89.  
  90. #define kUSBRegName        "\pUSB Ethernet External"        // Name registry name
  91. #define kDrvName         "\pUSB Enet "                    // Driver name - will be made unique by the shim if it is not
  92.  
  93. //  Miscellaneous 
  94.  
  95. enum
  96. {
  97.     kBufferSize = 1514,
  98.     kBufferPadSize = 24*64,                                // multiple of 64 (1536)
  99.     kNumOutBufs = 3,
  100.     kNumInBufs = 3,
  101.     kAvailable = 0,
  102.     kUnavailable = -1
  103. };
  104.     
  105. typedef    struct    Buffers
  106. {    
  107.     struct QElem     *qLink;
  108.     UInt16            avail;
  109.     UInt32            indx;
  110.     USBPB            bufPB;
  111.     UInt8            Buffer[kBufferPadSize];
  112.  
  113. } Buffers;
  114.  
  115. typedef struct Buffers *BuffersPtr;
  116.  
  117. // Global data structure
  118.  
  119. typedef    struct    ShimEnetGlobals
  120. {
  121.     //    input buffer(s)
  122.     Buffers                inBuf[kNumInBufs];                        //    not really a good way to do this but what the hey (for now)
  123.     ProcPtr                isr;                                    //    To notify receiver
  124.     UInt32                cookie;                                    //    With this parameter
  125.     QHdr                rcvq;                                    //    Receive queue
  126.     
  127.     //    output buffer(s)
  128.     Buffers                outBuf[kNumOutBufs];                    //    not really a good way to do this but what the hey (for now)
  129.     
  130.     //    miscellaneous
  131.  
  132.     ShimRefNum            ShimRef;            //    save the shim's reference number
  133.     Boolean                openSession;        //  only allow one open session
  134.     CFragConnectionID    ConnID;                //    connection to the shim
  135.     RegEntryID            theID;                //    our reg. ID
  136.     unsigned char        rname[20];            //    real driver name
  137.     
  138.     //    Install and remove CFM routines
  139.     
  140.     OSErr                 (*ShimInstall) (EnetShimInterface IntBlk, ShimRefNum *ref);
  141.     OSErr                 (*ShimRemove) (ShimRefNum ref, Boolean forced);
  142.     OSErr                 (*ShimAsync) (ShimRefNum ref, UInt16 DvrSelector, UInt32 Value1, UInt32 Value2);
  143.  
  144. } ShimEnetGlobals;
  145.  
  146. extern    ShimEnetGlobals    *gGlobals;
  147.  
  148. #endif